Skip to content

Avoid calling PHP directly in build process#11335

Closed
desrosj wants to merge 1 commit intoWordPress:trunkfrom
desrosj:fix/php-requirement-for-build-script
Closed

Avoid calling PHP directly in build process#11335
desrosj wants to merge 1 commit intoWordPress:trunkfrom
desrosj:fix/php-requirement-for-build-script

Conversation

@desrosj
Copy link
Copy Markdown
Member

@desrosj desrosj commented Mar 23, 2026

This removes the php command in the build script introduced in r61873.

Trac ticket: Core-64925

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code
Model(s): Sonnet 4.6
Used for: Used to create the first draft of this PR.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@desrosj desrosj self-assigned this Mar 23, 2026
@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@desrosj desrosj marked this pull request as ready for review March 23, 2026 16:24
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 23, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props desrosj, dmsnell.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dmsnell
Copy link
Copy Markdown
Member

dmsnell commented Mar 24, 2026

I think when I added the original code I saw that the PHP files included an if ( ! defined( 'ABSPATH' ) ) { die(); } check. it’s unclear from the code what the purpose of fromString does, and how it parses the PHP code.

with require file_get_contents( 'php://stdin' ); we at least know that we expect the included PHP to return a value, and that value will be serialized.

I had to perform a couple web searches to find the php-array-reader and then to find the php-parser node module it depends on to begin to get a faint picture of what it’s doing and how it’s written.


I’m still perplexed by how this is a problem, and what makes this particular build step distinct from the other basic requirements of PHP. is running all of this in npm ci via a post-install hook the actual problem? because it seems like this should be doable within the Docker image, if that’s what someone is doing, or plainly via php if running outside of Docker.

While I don’t want to delay any changes that are necessary, I’m just wanting to double-check our values when introducing more npm dependencies to booting the repo, running more JS code to recreate a PHP parser when one is available to us already, and where we know we need php anyway.

@desrosj
Copy link
Copy Markdown
Member Author

desrosj commented Mar 26, 2026

I’m still perplexed by how this is a problem, and what makes this particular build step distinct from the other basic requirements of PHP. is running all of this in npm ci via a post-install hook the actual problem? because it seems like this should be doable within the Docker image, if that’s what someone is doing, or plainly via php if running outside of Docker.

While I don’t want to delay any changes that are necessary, I’m just wanting to double-check our values when introducing more npm dependencies to booting the repo, running more JS code to recreate a PHP parser when one is available to us already, and where we know we need php anyway.

While it's true that WordPress cannot be run without PHP, the build script has never required PHP to be present to prepare wordpress-develop for use. The only requirement to build wordpress-develop was Node.js/npm.

While it's true that it could be run within the Docker image, many contributors do not use the local Docker environment at all, and requiring someone to pull large containers (the latest image for just wordpress/php is nearly 350MB) just to build the code is not ideal. Running commands like this within the containers also tends to be much slower.

@desrosj desrosj force-pushed the fix/php-requirement-for-build-script branch from 87e0591 to 396aef8 Compare March 27, 2026 00:00
Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and tests well.

Testing notes:

  • Unlinked PHP installations (via brew unlink)
  • Checkout trunk
  • Run npm run grunt clean:qunit; npm run build:dev
  • Reproduced build error seen on GH actions
  • Observed changes to the generated script loader files
  • Checkout this PR
  • Run npm run grunt clean:qunit; npm run build:dev
  • Completed error free
  • Observed the generated script loader files matched the committed versions

I am satisfied that the npm package introduced is currently maintained.

@github-actions
Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62157
GitHub commit: 9aa1bdd

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants